package com.md.livingwidget.emptyview;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.md.livingwidget.R;

import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;

/**
 * 项目名称：com.yxt.baseic_ui_frame.emptyview
 * 类名称：PHEmptyViewUI
 * 类描述：空样式
 * 创建人：wuht
 * 创建时间：2020-01-10 14:47
 */
public class PHEmptyViewUI extends FrameLayout {

    private ImageView emptyImageView;
    private TextView emptyTextView;
    private TextView emptySubTextView;


    public PHEmptyViewUI(Context context) {
        this(context, null);
    }

    public PHEmptyViewUI(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public PHEmptyViewUI(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }

    protected void initView() {
        View.inflate(getContext(), R.layout.ph_empty_layout, this);
        emptyImageView = findViewById(R.id.image_empty);
        emptyTextView = findViewById(R.id.tv_empty_text);
        emptySubTextView = findViewById(R.id.tv_empty_sub_text);
    }

    public void setEmptyImage(@DrawableRes int res) {
        if (emptyImageView != null) {
            emptyImageView.setImageResource(res);
        }
    }

    public void setEmptyText(String text) {
        if (emptyTextView != null) {
            emptyTextView.setText(text);
        }
    }

    public void setEmptySubText(String text) {
        if (emptySubTextView != null) {
            emptySubTextView.setText(text);
        }
    }


}
